/*
 ============================================================================
 Name		: fTimer.h
 Author	  : wangchao
 Version	 : 1.0
 Copyright   : 
 Description : CfTimer declaration
 ============================================================================
 */

#ifndef FTIMER_H
#define FTIMER_H

#include <e32base.h>	// For CActive, link against: euser.lib
#include <e32std.h>		// For RTimer, link against: euser.lib
class fTimer : public CActive
{
public:
    // Cancel and destroy
    ~fTimer( );

    // Two-phased constructor.
    static fTimer* NewL( );

    // Two-phased constructor.
    static fTimer* NewLC( );

public:
    // New functions
    // Function for making the initial request
    void StartL( TTimeIntervalMicroSeconds32 aDelay );

private:
    // C++ constructor
    fTimer( );

    // Second-phase constructor
    void ConstructL( );

private:
    // From CActive
    // Handle completion
    void RunL( );

    // How to cancel me
    void DoCancel( );

    // Override to handle leaves from RunL(). Default implementation causes
    // the active scheduler to panic.
    TInt RunError( TInt aError );

private:
    enum TfTimerState
    {
        //
        EUninitialized, // Uninitialized
        EInitialized, // Initalized
        EError, // Error condition
        EEnd
    };

private:
    TInt iState; // State of the active object
    RTimer iTimer; // Provides async timing service
};

#endif // FTIMER_H
